package com.power.project.model;


import com.power.common.domain.BaseModel;
import com.power.common.util.NanoidUtil;
import com.power.project.model.bo.TagSaveBO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
*  标签实体类
*/

@Entity
@ApiModel(value="标签")
@Data
@Table(name="Ww_tag")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
//@IdClass(Ww_tag.Ww_tagPK.class) 用于复合组件
public class Ww_tag extends BaseModel implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "")
    private Integer id;

    @ApiModelProperty(value = "标签id")
    private String tagid;

    @ApiModelProperty(value = "标签名称")
    private String name;

    @ApiModelProperty(value = "租户id")
    private String tenantid;

    public Ww_tag(TagSaveBO saveBO) {
        this.tagid = NanoidUtil.randomTmNanoId();
        this.name = saveBO.getName();
        this.tenantid = saveBO.getTenantId();
    }


    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("tagid", this.getTagid());
        map.put("name", this.getName());
        map.put("tenantid", this.getTenantid());
        return map;
    }

    public Serializable getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (Integer) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Ww_tagPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (Integer)key;

        //Ww_tagPK pk = (Ww_tagPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}